<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link href="../css/style_wln.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../js/calendar.js"></script>
</head>

<script type="text/javascript">
    var value = window.location.href;
    var arr = value.substring(value.lastIndexOf('?') + 1,value.length).split('&');
    var info = new Array();
    for(var i = 0; i < arr.length; i++){
        info[arr[i].split('=')[0]] = arr[i].split('=')[1];
    }

    //通过参数得到页面设计

    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

    function onloadCalendar(){
        var temp = new Date();
        var year = temp.getFullYear();
        var month = temp.getMonth()+1;
        var day = temp.getDate();
        //alert('year = '+year+',month='+month+',day='+day);
        selectCalendar(year, month, day);
    }

    function selectCalendar(year, month,day){
        var temp = new Date(year,month,0);
        var monthday = temp.getDate();
        var firstDay = new Date(year+"/"+month+"/01");
        var firstDay_Week = firstDay.getDay();//获取当前星期X(0-6,0代表星期天)
        var display_line_num = Math.ceil((firstDay_Week+1+monthday)/7);//通过第一天星期几加上天数，就可以知道这个月显示多少行
        var all_date = "";
//        alert(firstDay_Week);
        firstDay.setDate(firstDay.getDate()-firstDay_Week);

        var calendar_week = '<p style="color: #b04343;">日</p><p>一</p><p>二</p><p>三</p><p>四</p><p>五</p><p style="color: #b04343">六</p>';
        document.getElementById("calendar_week").innerHTML = calendar_week;

        for(var i = 0;i<7*display_line_num;i++){
//            all_date += firstDay.Format('yyyy-MM-dd')+"    ";
            var f_year = firstDay.getFullYear();
            var f_month = firstDay.getMonth() + 1;
            var f_day = firstDay.getDate();

            var nl_data = calendar.solar2lunar(f_year,f_month,f_day);
//            alert(nl_data);
//            eval("var nl_json = " + nl_data);
//            alert("aa");
            var nl = nl_data.IDayCn;
            if(f_year == year && f_month == month){
                if(f_day == day){
                    all_date += '<div class="this_day"><p>'+f_day+'</p><p>'+nl+'</p></div>';
                }else{
                    all_date += '<div class="this_month"><p>'+f_day+'</p><p>'+nl+'</p></div>';
                }
            }else{
                all_date += '<div class="other_month"><p>'+f_day+'</p><p>'+nl+'</p></div>';
            }
            if(i>0&&i%7==6){all_date+="<br>";}
            firstDay.setDate(firstDay.getDate()+1);
        }
        document.getElementById("calendar_date").innerHTML = all_date;
//        alert(all_date);

        /*var temp = new Date(year,month,0);
        alert(temp.getDate());//得到某个月的天数
        */
//        var firstDay = new Date(year+"/"+month+"/01");
//        alert(firstDay.Format('yyyy-MM-dd'))
    }

    window.onload=onloadCalendar;
</script>
<body style="width: 100%;">
    <div class="title red_write">
        <p><a href="wln.html">返回</a></p>
        <p>适合嫁娶的日子</p>
    </div>

    <div class="main_content">
        <!-- BEGIN #main -->
        <div class="calendar_area">
            <div id="calendar_week">
            </div>
            <div id="calendar_date">
            </div>
        </div>

        <div class="zr_filter">
            <p class="display_inline_block color_glod">筛选器</p>
            <div class="first_input display_inline_block color_glod"><input type="checkbox">  仅周末</div>
            <div class="other_input display_inline_block color_glod"><input type="checkbox">  含6、8</div>
        </div>
        <div class="zr_recommend">
            <div class="color_cyan_red">一周之内吉日:12月18日，天气：晴</div>
            <div class="color_cyan_red">一月之内吉日:12月24日，天气：晴</div>
        </div>

        <div class="zr_desc">
            <p class="color_cyan_red">婚嫁习俗</p>
            <div class="color_glod">详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容
                详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容详细内容
            </div>
        </div>
    </div>
</body>
</html>